  
const express = require('express')
const router = express.Router()
const publicController = require('../controllers/public')
const productController = require('../controllers/product')
const userController = require('../controllers/user')
const powerController = require('../controllers/power')
const phoneController = require('../controllers/phone')
const roleRightController = require('../controllers/roleRight')

/*
  公共api
*/

// 用户登入
router.post('/login', publicController.userLogin)
// 获取菜单列表
router.get('/list', publicController.getMenuList)

/*
  商品api
 */

// 获取商品列表
router.get('/product', productController.getProductList)

// 创建商品类别
router.post('/addProduct', productController.createMulit)

router.post('/addState', productController.createSpecial)

router.get('/class/:id/attributes', productController.showProductState)

router.put('/class/:id/attribute/:StateId', productController.addDynamic)

router.post('/proAdd', productController.getProInfo)

router.get('/prolist', productController.getProList)

router.post('/upload', productController.getPic)

router.post('/adNew', productController.addNewPro)

router.delete('/delPro/:_id', productController.deletePro)

router.get('/ording', productController.getOrding)
/* 
  用户api
*/

// 获取用户列表
router.get('/users', userController.getUserList)
// 添加用户
router.post('/register', userController.addUser)
// 删除用户
router.delete('/users/:_id', userController.deleteUser)
// 编辑用户
router.put('/register/:_id', userController.updataUser)


/*
  权限api
*/

// 获取角色列表
router.get('/role', powerController.getRoleList)
// 获取分配权限列表
router.get('/right', powerController.getRightList)
// 获取全部权限列表
router.get('/powerlist', powerController.getPowerList)
// 删除用户权限
router.delete('/power/:_id', powerController.updateRoleRight)


/*
手机
*/

router.post('/phone', phoneController.createSystem)

router.post('/brand', phoneController.createBrand)

router.post('/info', phoneController.createPhone)

router.get('/phoneList', phoneController.findPhone)

router.post('/multi',phoneController.createMulit)

router.post('/ad',phoneController.createSpecial)

router.delete('/dt',phoneController.deleteTest)

/*
 角色权限
 */

 router.post('/adRole', roleRightController.createMulit)

 router.post('/adThree', roleRightController.addThreeRight)

 router.post('/adSecond', roleRightController.addSecondRight)

 router.post('/adRight', roleRightController.addRightance)

 router.delete('/dtSecond', roleRightController.deleteSecondRight)

 router.delete('/dtThree', roleRightController.deleteThreeRight)

 router.delete('/dtRole', roleRightController.deleteRole)

 router.get('/roleList', roleRightController.getRoleRight)

 router.get('/rightList', roleRightController.getAllRight)

 router.post('/dispeach', roleRightController.dispatchRight)

 router.get('/allRoles', roleRightController.getRoleList)

module.exports = router